<?php

namespace Data;

/**
 * Description of Redata
 *
 * @author saisai
 */
class Redata
{

    /**
     * 返回失败消息
     * @param type $msg
     * @param type $data
     * @param type $type
     * @param type $action
     * @return type
     */
    static function error($msg, $data = [], $type = '', $action = '')
    {
        empty($data) && $data  = $msg;
        $data2 = [
            'type'      => 'redata',
            're_type'   => $type,
            're_action' => $action,
            'data'      => $data,
            'msg'       => $msg,
            'status'    => 400
        ];
        dump($data2);
        return json_encode($data2);
    }

    /**
     * 返回成功消息
     * @param type $msg
     * @param type $data
     * @param type $type
     * @param type $action
     * @return type
     */
    static function success($msg, $data = [], $type = '', $action = '')
    {
        empty($data) && $data = $msg;

        $data2 = [
            'type'      => 'redata',
            're_type'   => $type,
            're_action' => $action,
            'data'      => $data,
            'msg'       => $msg,
            'status'    => 200
        ];
        dump($data2);
        return json_encode($data2);
    }

}
